﻿using System;
using System.Xml.Serialization;
using Kotonoha.Objects.SuperMemo;

namespace Kotonoha.Objects.Model {
    /// <summary>
    /// Represents a japanese word with reading and translations
    /// </summary>
    public class Word
    {
        [XmlAttribute]
        public string Writing { get; set; }
        [XmlAttribute]
        public string Reading { get; set; }
        
        public string[] Translations { get; set; }

        public Example[] Examples { get; set; }

        [XmlAttribute]
        public long Id { get; set; }

        [XmlAttribute]
        public DateTime AddedDate { get; set; }

        public ItemLearningData LearningData { get; set; }

        private SerializableDictionary<string, string> additional = new SerializableDictionary<string, string>();
        
        [XmlIgnore]
        public SerializableDictionary<string, string> Additional {
            get { return additional; }
            set { additional = value; }
        }

        public int getAdditionalInt(string name, int defVal) {
            string s;
            if (!additional.TryGetValue(name, out s)) {
                return defVal;
            }
            return int.Parse(s);
        }
    }

    /// <summary>
    /// Represents example sentence
    /// </summary>
    public class Example {
        public string Content { get; set; }
        public string Translation { get; set; }
    }
}